import request from '@/utils/request'

// 新增
export function addMenu(data) {
  return request({
    url: '/sys/menu/add',
    method: 'post',
    params: data
  })
}
// 加载树形表格
export function listMenu(query) {
  return request({
    url: '/sys/menu/list',
    method: 'post',
    params: query
  })
}

// 查询菜单下拉树结构
export function selectTreeMenu() {
  return request({
    url: '/sys/menu/selectTree',
    method: 'post'
  })
}

// 更新菜单
export function updateMenu(data) {
  return request({
    url: '/sys/menu/update',
    method: 'post',
    params: data
  })
}

// 查找

export function getMenuByMenuId(menuId) {
  return request({
    url: '/sys/menu/get/' + menuId,
    method: 'get'
  })
}
// 删除菜单
export function delMenu(menuId) {
  return request({
    url: '/sys/menu/remove/' + menuId,
    method: 'get'
  })
}

// 校验菜单名称
export function checkMenuNameUnique(menuId, parentId, menuName) {
  const data = {
    'menuId': menuId,
    'parentId': parentId,
    'menuName': menuName
  }
  return request({
    url: '/sys/menu/checkMenuNameUnique',
    method: 'post',
    params: data
  })
}
// 校验菜单url
export function checkMenuUrlUnique(menuId, parentId, url) {
  const data = {
    'menuId': menuId,
    'parentId': parentId,
    'url': url
  }
  return request({
    url: '/sys/menu/checkMenuUrlUnique',
    method: 'post',
    params: data
  })
}
// 查询菜单下拉树结构(全部)
export function selectTreeMenuAll(data) {
  return request({
    url: '/sys/menu/selectCompMenuTree',
    method: 'post',
    params: data
  })
}

// 获取菜单最大序号值
export function getMaxMenuSort() {
  return request({
    url: '/sys/menu/getDataCount',
    method: 'get'
  })
}
